// license-header java merge-point
/**
 * This is only generated once! It will never be overwritten.
 * You can (and have to!) safely modify it by hand.
 */
package com.myplans.model;

import java.util.List;

import org.hibernate.Criteria;

import com.myplans.vo.CategoryValue;

/**
 * @see com.myplans.model.Category
 */
public class CategoryDaoImpl
    extends com.myplans.model.CategoryDaoBase
{
    /**
     * @see com.myplans.model.CategoryDao#toCategoryValue(com.myplans.model.Category, com.myplans.vo.CategoryValue)
     */
    public void toCategoryValue(
        com.myplans.model.Category source,
        com.myplans.vo.CategoryValue target)
    {
        // @todo verify behavior of toCategoryValue
        super.toCategoryValue(source, target);
    }


    /**
     * @see com.myplans.model.CategoryDao#toCategoryValue(com.myplans.model.Category)
     */
    public com.myplans.vo.CategoryValue toCategoryValue(final com.myplans.model.Category entity)
    {
        // @todo verify behavior of toCategoryValue
        return super.toCategoryValue(entity);
    }


    /**
     * Retrieves the entity object that is associated with the specified value object
     * from the object store. If no such entity object exists in the object store,
     * a new, blank entity is created
     */
    private com.myplans.model.Category loadCategoryFromCategoryValue(com.myplans.vo.CategoryValue categoryValue)
    {
    	Category category = Category.Factory.newInstance();
    	if (categoryValue.getId() != null) {
    		category = this.load(categoryValue.getId());
    	}
        return category; 
    }

    
    /**
     * @see com.myplans.model.CategoryDao#categoryValueToEntity(com.myplans.vo.CategoryValue)
     */
    public com.myplans.model.Category categoryValueToEntity(com.myplans.vo.CategoryValue categoryValue)
    {
        // @todo verify behavior of categoryValueToEntity
        com.myplans.model.Category entity = this.loadCategoryFromCategoryValue(categoryValue);
        this.categoryValueToEntity(categoryValue, entity, true);
        return entity;
    }


    /**
     * @see com.myplans.model.CategoryDao#categoryValueToEntity(com.myplans.vo.CategoryValue, com.myplans.model.Category)
     */
    public void categoryValueToEntity(
        com.myplans.vo.CategoryValue source,
        com.myplans.model.Category target,
        boolean copyIfNull)
    {
        // @todo verify behavior of categoryValueToEntity
        super.categoryValueToEntity(source, target, copyIfNull);
    }
    
    /**
     * @see com.myplans.model.CategoryDao#getCategories(com.myplans.criteria.CategorySearchCriteria)
     */
    protected java.util.List<com.myplans.vo.CategoryValue> handleGetCategories(com.myplans.criteria.CategorySearchCriteria searchCriteria)
    {
    	Criteria criteria = getSession().createCriteria(Category.class);
         
 		List result = criteria.list();
        toCategoryValueCollection(result);
        return (List<CategoryValue>) result;
    }


}